package com.fulong.dao;

import com.fulong.entity.DeviceLendRecordEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 
 * 
 * @author fulong
 * @email ${email}
 * @date 2022-03-27 19:36:41
 */
@Mapper
public interface DeviceLendRecordDao extends BaseMapper<DeviceLendRecordEntity> {
	@Select("select a.* , b.label as devicename ,c.`name` as username from \n" +
            "device_lend_record as a \n" +
            "LEFT JOIN (\n" +
            "\tSELECT e.id , d.label\n" +
            "\tFROM\n" +
            "\tdevice_baise_info AS d\n" +
            "\tRIGHT  JOIN\n" +
            "\tdevice_manage_info AS e\n" +
            "\ton d.id = e.type\n" +
            ") as b ON a.deviceid = b.id \n" +
            "LEFT JOIN user_baise_info as c ON a.userid = c.id\n" +
            "LEFT JOIN device_manage_approver as f \n" +
            "on a.approverid = f.typeid\n" +
            "LEFT JOIN user_baise_info as g on g.id=f.approver\n" +
            "WHERE f.approver = #{approverid}")
    List<Map<String ,Object>> listApprover(String approverid);

    @Select("select a.* , b.label as devicename ,c.`name` as username from \n" +
            "device_lend_record as a \n" +
            "LEFT JOIN (\n" +
            "\tSELECT e.id , d.label\n" +
            "\tFROM\n" +
            "\tdevice_baise_info AS d\n" +
            "\tRIGHT  JOIN\n" +
            "\tdevice_manage_info AS e\n" +
            "\ton d.id = e.type\n" +
            ") as b ON a.deviceid = b.id \n" +
            "LEFT JOIN user_baise_info as c ON a.userid = c.id\n" +
            "where a.`status` BETWEEN 4 AND 9 or a.`status`=2")
    List<Map<String ,Object>> listApproverOutstock();

}
